<div class="action-dialog-model-fixed-body">
    <div class="detailsBox">
        <h3>仓库信息</h3>
        <form action="<@url value='/mainStoreInfoRest/save'/>" method="post" name="shopForm" class="action-ajax-form action-ajax-form-valid" >
            <div class="detaiTab">
                <input id="id" type="hidden" value="${view.id}" name="id">
                <input id="loanapplyNo" type="hidden" value="${loanapplyNo}" name="loanapplyNo">

                <table width="100%" cellspacing="0" cellpadding="0" border="0">
                  <tbody>
                    <tr>
                    	<td width="15%" align="right" class="bg"> 仓库性质：<font color="red">*</font> </td>
                        <td>
                        	<@select dataSouceType="storeNature" name="storeNature"  value="${view.storeNature}" class="action-valid-field" data\-action\-valid\-rule="required;" data\-action\-valid\-msg\-required="仓库性质不能为空！" />
                            <span class="action-field-error" for="storeNature" style="color:red;"></span>
                        </td>
                    	<td width="15%" align="right" class="bg">仓库类型：<font color="red">*</font> </td>
                        <td>
                        	<@select dataSouceType="storeType" name="storeType"  value="${view.storeType}" class="action-valid-field" data\-action\-valid\-rule="required;" data\-action\-valid\-msg\-required="仓库性质不能为空！" />
                            <span class="action-field-error" for="storeType" style="color:red;"></span>
                        </td>
                    </tr>
                    <tr>
                       <td width="15%" align="right" class="bg"> 仓库地址：<font color="red">*</font> </td>
                        <td colspan="3">
                            <span id="ckdz"><@select dataSouceType="province" name="storeprovince"  id="select_store_provinceId" value="${view.storeprovince}" onchange="storeprovinceOnchange()" />
                            &nbsp;&nbsp; <@select dataSouceType="city" dataSouceFrom="${view.storeprovince}" name="storecity"  id="select_store_cityId" value="${view.storecity}" onchange="storecityOnchange()" />
                            &nbsp;&nbsp; <@select dataSouceType="country" dataSouceFrom="${view.storecity}" name="storecounty"  id="select_store_districtId" value="${view.storecounty}"/>
                            &nbsp;&nbsp; <input type="text"  id="storeaddress" value="${view.storeaddress}" size="50" name="storeaddress" class="action-valid-field" data-action-valid-rule="required;maxlength:50;" data-action-valid-msg-required="仓库地址不能为空！"  autocomplete="off" />
                            <span class="action-field-error" for="storeaddress" style="color:red;"></span>&nbsp;&nbsp;
                            <a href="javascript:void(0);" target="_blank" onclick="ckdzmap(this)">地图中查看</a>
                        </td>
                    </tr>
                    
                    
                     <tr>
                        <td width="15%" align="right" class="bg"> 面积：<font color="red">*</font> </td>
                        <td >
                            <input type="text"  id="acreage" value="${view.acreage}" size="30" name="acreage" class="action-valid-field" data-action-valid-rule="required;maxlength:30;number;reg:^[1-9]\d*$;" data-action-valid-msg-required="面积不能为空！"  autocomplete="off" />
                            <span class="action-field-error" for="acreage" style="color:red;"></span>
                        </td>
                        <td width="15%" align="right" class="bg">年租金：<font color="red">*</font> </td>
                        <td >
                            <input type="text"  id="rent" value="${view.rent}" size="30" name="rent" class="action-valid-field" data-action-valid-rule="required;maxlength:30;number;reg:^[1-9]\d*$;" data-action-valid-msg-required="年租金不能为空！"  autocomplete="off" />
                            <span class="action-field-error" for="rent" style="color:red;"></span>
                        </td>
                    </tr>
                    
                    <tr>
                    	<td width="15%" align="right" class="bg"> 租赁合同起止日期 ：<font color="red">*</font> </td>
                        <td >
                        	<@date value="${view.rentStartDate}" id="rentStartDate" name="rentStartDate" class="action-valid-field" data\-action\-valid\-rule="required;" data\-action\-valid\-msg\-required="租赁合同起日期不能为空！" autocomplete="off"/>
                            <span class="action-field-error" for="rentStartDate" style="color:red;"></span>
                            -
                            <@date value="${view.rentEndDate}" id="rentEndDate" name="rentEndDate" class="action-valid-field" data\-action\-valid\-rule="required;" data\-action\-valid\-msg\-required="租赁合同止日期不能为空！" autocomplete="off"/>
                            <span class="action-field-error" for="rentEndDate" style="color:red;"></span>
                            <span id="rentDateError" style="color:red;visibility:visible;"></span>
                        </td>
                        <td width="15%" align="right" class="bg"> 存货价值预估：<font color="red">*</font> </td>
                        <td >
                            <input type="text"  id="stock" value="${view.stock}" size="30" name="stock" class="action-valid-field" data-action-valid-rule="required;maxlength:30;" data-action-valid-msg-required="存货价值预估不能为空！"  autocomplete="off" />
                            <span class="action-field-error" for="stock" style="color:red;"></span>
                        </td>
                    </tr>
                    
                    <tr>
                        <td width="15%" align="right" class="bg">存货的交叉验证：<font color="red">*</font> </td>
                        <td colspan="3">
							<@select type="checkbox" dataSouceType="stockType_JC" name="stockType" value="${view.stockType}" id="stockType"
								class="action-valid-field" 
                        		 data\-action\-valid\-rule="required;" data\-action\-valid\-msg\-required="存货的交叉验证不能为空！"/>
                            <span class="action-field-error" for="stockType" style="color:red;"></span>
                        </td>
                    </tr>    
                    
                    <tr>
                        <td width="15%" align="right" class="bg"> 进货周期（旺季）：<font color="red">*</font> </td>
                        <td>
                        	<@select dataSouceType="isStock" name="isStock"
                       			 id="isStock" value="${view.isStock}" class="action-valid-field" 
                        		 data\-action\-valid\-rule="required;" data\-action\-valid\-msg\-required="进货周期（旺季）不能为空！" />
                            <span class="action-field-error" for="isStock" style="color:red;"></span>
                        </td>
                        <td width="15%" align="right" class="bg"> 平均进货量/次（元）：<font color="red">*</font> </td>
                        <td >
                           	<input type="text"  id="stockMoney" value="${view.stockMoney}" size="30" name="stockMoney" class="action-valid-field" data-action-valid-rule="required;maxlength:30;number;reg:^[1-9]\d*$;" data-action-valid-msg-required="平均进货量/次不能为空！" autocomplete="off" />
                            <span class="action-field-error" for="stockMoney" style="color:red;"></span>
                        </td>
                    </tr>
                    
                    <tr>
                    	<td width="15%" align="right" class="bg"> 存货效期描述：<font color="red">*</font> </td>
                        <td colspan='3'>
                            <textarea name="ps" cols="60" rows="4" maxlength="1000" placeholder="描述（1000字以内）" 
                            	class="action-valid-field" data-action-valid-rule="required;maxlength:1000;" data-action-valid-msg-required="存货效期描述不能为空！" autocomplete="off">${view.ps}</textarea>
                            <span class="action-field-error" for="ps" style="color:red;"></span>
                        </td>
                    </tr>
                    
                  </tbody>
                </table>
            </div>
            

            <div class="clearfix tac mtb20">
                <input type="submit" class="btn_auto_30 btn_blue" value="提交" onclick="return check();">&nbsp;
            </div>
        </form>

 
    </div>

    </div>
   <@js>
   
   function check(){
	  var loanDate1=$("#rentStartDate").val();
	  var loanDate2=$("#rentEndDate").val();
	  var date1 = new Date(loanDate1.replace(/\-/g, "\/"));
	  var date2 = new Date(loanDate2.replace(/\-/g, "\/"));
	  if(date1>date2){
      	$("#rentDateError").html("结束时间必须大于开始时间");
      	$("#rentDateError").css('visibility','visible');
      	return false; 
	  }else {
	  	$("#rentDateError").html("");
      	$("#rentDateError").css('visibility','hidden'); 
	 	return true;
	  }
	}
   
function bgdzmap(obj){
	var location = $('#bgdz').html().replace(/[\r\n &nbsp;]/g,'');
	obj.href='http://api.map.baidu.com/geocoder?address='+location+'&output=html&src=';
}

function mddzmap(obj){
	var location = $('#mddz').html().replace(/[\r\n &nbsp;]/g,'');
	obj.href='http://api.map.baidu.com/geocoder?address='+location+'&output=html&src=';
}

function yyzzdzmap(obj){
	var location = $('#yyzzdz').html().replace(/[\r\n &nbsp;]/g,'');
	obj.href='http://api.map.baidu.com/geocoder?address='+location+'&output=html&src=';
}

function ckdzmap(obj){
	var location = $('#ckdz').html().replace(/[\r\n &nbsp;]/g,'');
	obj.href='http://api.map.baidu.com/geocoder?address='+location+'&output=html&src=';
}

	$(function() {
		var loanType = $('#loanType').val();
		var sdurl = '/oaoro2odatasub/jsonword';
		if(loanType=='BP'||loanType=='BP_JX'||loanType=='SG'||loanType=='YC'||loanType=='SC'){
			var sdurl = '/oaoro2odatasub/jsonwordNew';
		}
		$('#shopnameRead').combogrid({
				loadMsg:'数据加载中,请稍后...',
				panelWidth: 500,
				idField: 'cno',
				textField: 'cname',
				url: sdurl,
				method: 'get',
				 rownumbers:true,//序号   
		      collapsible:false,//是否可折叠的   
				columns: [[
					{field:'cno',title:'流水号',width:80},
					{field:'ccode',title:'客户sd号',width:120},
					{field:'cname',title:'客户名简称',width:150},
					{field:'cnames',title:'客户全称',width:150}
				]],
				fitColumns: true,
				delay: 1100,
				keyHandler: {
					up: function() {
					},
					down: function() {
					},
					enter: function() {
					},
					query: function(q) {
						if(loanType=='BK'){
							$('#shopnameRead').combogrid("grid").datagrid("reload", { 'reloadname': q });
								$('#shopnameRead').combogrid("setValue", q);
						}else{
							if(q||q.length>3){
								$('#shopnameRead').combogrid("grid").datagrid("reload", { 'reloadname': q });
								$('#shopnameRead').combogrid("setValue", q);
								item=true;
							}
						}
					}
				 },
				 onClickRow:function(rowIndex, rowData){
					$("#shopname").val(rowData.cname);
					$("#shopno").val(rowData.cno);
					$("#shopcode").val(rowData.ccode);
				},
				onLoadSuccess:function(){
				}
			});
		})

   provinceOnchange();
        function provinceOnchange(){
        var provinceCode = $("#select_provinceId").val();
        var url="<@url value='/common/findCityByProvinceCode' domain='${crmUrl}'/>";
        $.ajax({
        type: "GET",
        url:url,
        data:{provinceCode:provinceCode},
        dataType:"jsonp",
        jsonp:"_callback",
        success:function(result){
   var t = $("#select_cityId").find("option:selected").text();
        $("#select_cityId").empty();
        $("#select_cityId").append("<option value=''>请选择</option>");

        $.each(result.data,function(key,value){
   if(t==value[1]){
   $("#select_cityId").append("<option selected = 'selected' value='"+value[0]+"'>"+value[1]+"</option>");
   }else{
   $("#select_cityId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");
   }
        });
        }
        });
   cityOnchange();
        }


        function cityOnchange(){
        var cityCode = $("#select_cityId").val();
        var url="<@url value='/common/findDistrictByCityCode' domain='${crmUrl}'/>";
        $.ajax({
        type: "GET",
        url:url,
        data:{cityCode:cityCode},
        dataType:"jsonp",
        jsonp:"_callback",
        success:function(result){
   var t = $("#select_districtId").find("option:selected").text();
        $("#select_districtId").empty();
        $("#select_districtId").append("<option value=''>请选择</option>");

        $.each(result.data,function(key,value){
   if(t==value[1]){
   $("#select_districtId").append("<option selected = 'selected' value='"+value[0]+"'>"+value[1]+"</option>");
   }else{
   $("#select_districtId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");
   }
        });
        }
        });
        }

        function shopprovinceOnchange(){
        var provinceCode = $("#select_shop_provinceId").val();
        var url="<@url value='/common/findCityByProvinceCode' domain='${crmUrl}'/>";
        $.ajax({
        type: "GET",
        url:url,
        data:{provinceCode:provinceCode},
        dataType:"jsonp",
        jsonp:"_callback",
        success:function(result){
   var t = $("#select_shop_cityId").find("option:selected").text();
        $("#select_shop_cityId").empty();
        $("#select_shop_cityId").append("<option value=''>请选择</option>");

        $.each(result.data,function(key,value){
   if(t==value[1]){
   $("#select_shop_cityId").append("<option selected = 'selected' value='"+value[0]+"'>"+value[1]+"</option>");
   }else{
   $("#select_shop_cityId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");
   }
        });
        }
        });
   shopcityOnchange();
        }


        function shopcityOnchange(){
        var cityCode = $("#select_shop_cityId").val();
        var url="<@url value='/common/findDistrictByCityCode' domain='${crmUrl}'/>";
        $.ajax({
        type: "GET",
        url:url,
        data:{cityCode:cityCode},
        dataType:"jsonp",
        jsonp:"_callback",
        success:function(result){
   var t = $("#select_shop_districtId").find("option:selected").text();
        $("#select_shop_districtId").empty();
        $("#select_shop_districtId").append("<option value=''>请选择</option>");

        $.each(result.data,function(key,value){
   if(t==value[1]){
   $("#select_shop_districtId").append("<option selected = 'selected' value='"+value[0]+"'>"+value[1]+"</option>");
   }else{
   $("#select_shop_districtId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");
   }
        });
        }
        });
        }
        
        function storeprovinceOnchange(){
        var provinceCode = $("#select_store_provinceId").val();
        var url="<@url value='/common/findCityByProvinceCode' domain='${crmUrl}'/>";
        $.ajax({
        type: "GET",
        url:url,
        data:{provinceCode:provinceCode},
        dataType:"jsonp",
        jsonp:"_callback",
        success:function(result){
   var t = $("#select_store_cityId").find("option:selected").text();
        $("#select_store_cityId").empty();
        $("#select_store_cityId").append("<option value=''>请选择</option>");

        $.each(result.data,function(key,value){
   if(t==value[1]){
   $("#select_store_cityId").append("<option selected = 'selected' value='"+value[0]+"'>"+value[1]+"</option>");
   }else{
   $("#select_store_cityId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");
   }
        });
        }
        });
   storecityOnchange();
        }


        function storecityOnchange(){
        var cityCode = $("#select_store_cityId").val();
        var url="<@url value='/common/findDistrictByCityCode' domain='${crmUrl}'/>";
        $.ajax({
        type: "GET",
        url:url,
        data:{cityCode:cityCode},
        dataType:"jsonp",
        jsonp:"_callback",
        success:function(result){
   var t = $("#select_store_districtId").find("option:selected").text();
        $("#select_store_districtId").empty();
        $("#select_store_districtId").append("<option value=''>请选择</option>");

        $.each(result.data,function(key,value){
   if(t==value[1]){
   $("#select_store_districtId").append("<option selected = 'selected' value='"+value[0]+"'>"+value[1]+"</option>");
   }else{
   $("#select_store_districtId").append("<option value='"+value[0]+"'>"+value[1]+"</option>");
   }
        });
        }
        });
        }

        $(function(){
        //1.配偶情况

        var shoptype=$("#shoptype").val();

        if(shoptype == 'MAN' ){
        $('#all_amount').show();
        $("input[name='totalAmount']").attr('data-action-valid-rule','required;');
        }else{
        $('#all_amount').hide();
        $("input[name='totalAmount']").removeAttr('data-action-valid-rule');
        }
        });

        $("#shoptype").change(function(){
        var shoptype=$("#shoptype").val();
        if(shoptype == 'MAN' ){
        $('#all_amount').show();
        $("input[name='totalAmount']").attr('data-action-valid-rule','required;');
        }else{
        $('#all_amount').hide();
        $("input[name='totalAmount']").removeAttr('data-action-valid-rule');
        }
        });
    </@js>
    <@jsRender/>